<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Aria: moduleExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Aria
   &#160;<span id="projectnumber">2.9.4</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('moduleExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">moduleExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>Example demonstrating how to load an ArModuleThis is a simple program that loads the module moduleExample_Mod, which is defined in moduleExample_Mod.cpp. The program simply calls <a class="el" href="classArModuleLoader.html#a63d2b1e8a16c3ebc8e34482f72499b23" title="Load an ArModule. ">ArModuleLoader::load()</a> with a short message argument and <a class="el" href="classArModuleLoader.html#aa43852d5d5ebbecebf8595a5a32015c2" title="Close and then reload an ArModule. ">ArModuleLoader::reload</a> with no argument and finally calls <a class="el" href="classArModuleLoader.html#a07f8693efb31b83b1203690ff2e632b3" title="Close an ArModule. ">ArModuleLoader::close()</a>. The return status of the load(), reload(), and close() are checked and printed out. <a class="el" href="classArModuleLoader.html" title="Dynamic ArModule loader. ">ArModuleLoader</a> uses the name of the module file without the platform-specific suffix (i.e. ".dll" on Windows and ".so" on Linux) to load the module.</p>
<dl class="section see"><dt>See also</dt><dd>moduleExample_Mod.cpp. </dd>
<dd>
<a class="el" href="classArModuleLoader.html" title="Dynamic ArModule loader. ">ArModuleLoader</a> in the reference manual.</dd></dl>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> printStatus(<a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4">ArModuleLoader::Status</a> status)</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (status == <a name="a0"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4aee4f0363dc85d4044d6e025ff9b201bb">ArModuleLoader::STATUS_ALREADY_LOADED</a>)</div><div class="line">    <a name="a1"></a><a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a2"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module already loaded.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a3"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4a9e0552cd4f9a42608051e62a98499a4d">ArModuleLoader::STATUS_FAILED_OPEN</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Failed to find or open the simpleMod module.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a4"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4a2b4cfa6d997517ad6b77ca6a7883cd4d">ArModuleLoader::STATUS_INVALID</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Invalid file.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a5"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4a40e62c3cdbbadeb5b2c0efe69b8648ed">ArModuleLoader::STATUS_INIT_FAILED</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module Init failed.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a6"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4a936b7a8cc20cc46acdd970cf7efab64e">ArModuleLoader::STATUS_SUCCESS</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module succedded.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a7"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4ab68f87a06fe705a7171a2248999bc1d7">ArModuleLoader::STATUS_EXIT_FAILED</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module exit sequence failed.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (status == <a name="a8"></a><a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4a748dad391df18837484389a9eee39eec">ArModuleLoader::STATUS_NOT_FOUND</a>)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module not found.&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Module returned unknown status!&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  <a name="a9"></a><a class="code" href="classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">  <a name="_a10"></a><a class="code" href="classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line">  parser.<a name="a11"></a><a class="code" href="classArArgumentParser.html#a501694b62a7f8b0c3cadd84aeafe1b35">loadDefaultArguments</a>();</div><div class="line">  <a name="_a12"></a><a class="code" href="classArRobot.html">ArRobot</a> robot;</div><div class="line"></div><div class="line">  <a name="_a13"></a><a class="code" href="classArRobotConnector.html">ArRobotConnector</a> robotConnector(&amp;parser, &amp;robot);</div><div class="line">  <span class="keywordflow">if</span>(!robotConnector.<a name="a14"></a><a class="code" href="classArRobotConnector.html#ab192ac393d9cc1e5b61b1a82b08d085d">connectRobot</a>())</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Could not connect to the robot.&quot;</span>);</div><div class="line">    <span class="keywordflow">if</span>(parser.<a name="a15"></a><a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">    {</div><div class="line">        <span class="comment">// -help not given</span></div><div class="line">        <a name="a16"></a><a class="code" href="classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">        <a name="a17"></a><a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">    }</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (!<a name="a18"></a><a class="code" href="classAria.html#a1b090c01d88bb420b8cf8e0384d25ee1">Aria::parseArgs</a>() || !parser.<a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">  {</div><div class="line">    <a class="code" href="classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">    <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a19"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;moduleExample: Connected to robot.&quot;</span>);</div><div class="line"></div><div class="line">  robot.<a name="a20"></a><a class="code" href="classArRobot.html#a3c3d878cfd11a2ef91230005a83bfcaa">runAsync</a>(<span class="keyword">true</span>);</div><div class="line"></div><div class="line">  <a class="code" href="classArModuleLoader.html#a98c3c3b3fa04816d2943582e373b63e4">ArModuleLoader::Status</a> status;</div><div class="line">  std::string str;</div><div class="line"></div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;moduleExample: Loading the module \&quot;moduleExample_Mod\&quot; with a string argument...&quot;</span>);</div><div class="line">  status=<a name="a21"></a><a class="code" href="classArModuleLoader.html#a63d2b1e8a16c3ebc8e34482f72499b23">ArModuleLoader::load</a>(<span class="stringliteral">&quot;./moduleExample_Mod&quot;</span>, &amp;robot, (<span class="keywordtype">char</span> *)<span class="stringliteral">&quot;You&#39;ve loaded a module!&quot;</span>);</div><div class="line">  printStatus(status);</div><div class="line">  <span class="comment">//ArLog::log(ArLog::Terse, &quot;moduleExample: Reloading the module with no argument...&quot;);</span></div><div class="line">  <span class="comment">//status=ArModuleLoader::reload(&quot;./moduleExample_Mod&quot;, &amp;robot);</span></div><div class="line">  <span class="comment">//printStatus(status);</span></div><div class="line"></div><div class="line">  <span class="comment">//ArLog::log(ArLog::Terse, &quot;moduleExample: Closing the module...&quot;);</span></div><div class="line">  <span class="comment">//status=ArModuleLoader::close(&quot;./moduleExample_Mod&quot;);</span></div><div class="line">  <span class="comment">//printStatus(status);</span></div><div class="line"></div><div class="line">  <a name="a22"></a><a class="code" href="group__easy.html#ga4dfb878a3f9123b8dd96ae05b2fd94cb">ArUtil::sleep</a>(3000);</div><div class="line"></div><div class="line">  <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">  <span class="keywordflow">return</span>(0);</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
